<?php 

include_once dirname(__FILE__)."/db.class.php" ;
 class email{
		 protected $_result;
		 protected $_cnn;
		 protected $_id_mail;
		 protected $_distinataire;
		 protected $_sender;
		 protected $_date_envoi;
		 protected $_heur_envoi;
		 protected $_sujet;
		 protected $_objet;
		 protected $_auteur;
		 protected $_message;
		 protected $_etat_sended;
		 protected $_phase;
		 protected $_type_destintinataire;
		 protected $_code_ue;
		 public function get_name_table(){ return "email";}
		 public function get_name_id_mail(){ return "id_mail";}
		 public function get_name_distinataire(){ return "distinataire";}
		 public function get_name_sender(){ return "sender";}
		 public function get_name_date_envoi(){ return "date_envoi";}
		 public function get_name_heur_envoi(){ return "heur_envoi";}
		 public function get_name_sujet(){ return "sujet";}
		 public function get_name_objet(){ return "objet";}
		 public function get_name_auteur(){ return "auteur";}
		 public function get_name_message(){ return "message";}
		 public function get_name_etat_sended(){ return "etat_sended";}
		 public function get_name_phase(){ return "phase";}
		 public function get_name_type_destintinataire(){ return "type_destintinataire";}
		 public function get_name_code_ue(){ return "code_ue";}
		 public function set_id_mail($parametre){  $this->_id_mail=$parametre;}	
		 public function set_distinataire($parametre){  $this->_distinataire=$parametre;}	
		 public function set_sender($parametre){  $this->_sender=$parametre;}	
		 public function set_date_envoi($parametre){  $this->_date_envoi=$parametre;}	
		 public function set_heur_envoi($parametre){  $this->_heur_envoi=$parametre;}	
		 public function set_sujet($parametre){  $this->_sujet=$parametre;}	
		 public function set_objet($parametre){  $this->_objet=$parametre;}	
		 public function set_auteur($parametre){  $this->_auteur=$parametre;}	
		 public function set_message($parametre){  $this->_message=$parametre;}	
		 public function set_code_ue($parametre){  $this->_code_ue=$parametre;}	
		 public function set_etat_sended($parametre){  $this->_etat_sended=$parametre;}	
		 public function set_phase($parametre){  $this->_phase=$parametre;}	
		 public function set_type_destintinataire($parametre){  $this->_type_destintinataire=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_id_mail(){ return $this->_id_mail;}
		 public function get_distinataire(){ return $this->_distinataire;}
		 public function get_sender(){ return $this->_sender;}
		 public function get_date_envoi(){ return $this->_date_envoi;}
		 public function get_heur_envoi(){ return $this->_heur_envoi;}
		 public function get_sujet(){ return $this->_sujet;}
		 public function get_objet(){ return $this->_objet;}
		 public function get_auteur(){ return $this->_auteur;}
		 public function get_message(){ return $this->_message;}
		 public function get_etat_sended(){ return $this->_etat_sended;}
		 public function get_code_ue(){ return $this->_code_ue;}
		 public function get_phase(){ return $this->_phase;}
		 public function get_type_destintinataire(){ return $this->_type_destintinataire;}
public function __construct(){

		 	$this->_cnn=new Db();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 email(
			distinataire,
			sender,
			date_envoi,
			heur_envoi,
			sujet,
			objet,
			auteur,
			message,
			etat_sended,
			phase,
			type_destintinataire,
			code_ue)
 VALUES(
			'".$this->_distinataire."',
			'".$this->_sender."',
			'".$this->_date_envoi."',
			'".$this->_heur_envoi."',
			'".$this->_sujet."',
			'".$this->_objet."',
			'".$this->_auteur."',
			'".$this->_message."',
			'".$this->_etat_sended."',
			'".$this->_phase."',
			'".$this->_type_destintinataire."',
			'".$this->_code_ue."')";

$this->_result=$this->_cnn->query($sql);
 return $this->_result;
}

 public function UPDATE()
{

 $sql="UPDATE 
email SET 
		
distinataire='".$this->_distinataire."',		
sender='".$this->_sender."',		
date_envoi='".$this->_date_envoi."',		
heur_envoi='".$this->_heur_envoi."',		
sujet='".$this->_sujet."',		
objet='".$this->_objet."',		
auteur='".$this->_auteur."',		
message='".$this->_message."',		
etat_sended='".$this->_etat_sended."',		
phase='".$this->_phase."',		
type_destintinataire='".$this->_type_destintinataire."',
code_ue='".$this->_code_ue."'
								WHERE id_mail ='".$this->_id_mail."'";

$this->_result=$this->_cnn->query($sql);
 return $this->_result;
}

 public function DELETE(){

 $sql="DELETE FROM 
email 
 
									WHERE id_mail ='".$this->_id_mail."'";

$this->_result=$this->_cnn->query($sql);
 return $this->_result;
}

 public function TRANCATE(){

 $sql="DELETE FROM 
email ";

$this->_result=$this->_cnn->query($sql);
 return $this->_result;
}

 public function SELECT($constraint="")
{

$sql=" SELECT 
 		id_mail,
		distinataire,
		sender,
		date_envoi,
		heur_envoi,
		sujet,
		objet,
		auteur,
		message,
		etat_sended,
		phase,
		type_destintinataire,
		code_ue
 FROM 
 email";
if($constraint){$sql.=" WHERE ".$constraint;}
//echo $sql;
$this->_result=$this->_cnn->query($sql);
 return $this->_result;
}

public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($row){
		$this->_id_mail=$row->id_mail;
		$this->_distinataire=$row->distinataire;
		$this->_sender=$row->sender;
		$this->_date_envoi=$row->date_envoi;
		$this->_heur_envoi=$row->heur_envoi;
		$this->_sujet=$row->sujet;
		$this->_objet=$row->objet;
		$this->_auteur=$row->auteur;
		$this->_message=$row->message;
		$this->_etat_sended=$row->etat_sended;
		$this->_phase=$row->phase;
		$this->_code_ue=$row->code_ue;
		$this->_type_destintinataire=$row->type_destintinataire;
		return true;
		}else{
					return false;
				}

		}
}
?>